#pragma once
#include "../include/football/FootBallMatch.h"
#define MAX_PLAYER_TYPE 8
#define MAX_POS 5
enum PLAYERTYPE{ GOALKEEPER, LEFTPLAYER, RIGHTPLAYER, CENTERPLAYER, DEFENCEPLAYER, ATTACKPLAYER, ATTACKPLAYERLEFT, ATTACKPLAYERRIGHT };
const int AREA_SAFE_CHECK = 70;
const int AREA_ACTIVITE_HEIGHT = PITCH_HEIGHT/2;
const int AREA_ACTIVITE_WIDTH = PITCH_WIDTH/2;
struct area{
	vector2d point;
	double width, height;
	area(vector2d center, double wid, double hei){
		point = center;
		width = wid;
		height = hei;
	};
};
class AIPlayer
{
private:
	
	int action;
	double distance2Ball;
	float regHeight, regWidth; // religion activiti
	vector2d defaultPos;
	vector2d currentPos;
	vector2d targetPos;
	double foce;
	
public:
	PLAYERTYPE typePlayer;
	double timeComplete;

	static void InitPlayerType(int);
	static void ResetPosToShoot(int);
	bool hasBall;
	bool isClosest;
	AIPlayer(void);
	~AIPlayer(void);
	void SetFoce(double _foce);	
	double GetFoce();
	void SetTarget(vector2d target);
	void SetAction(int _action);
	void SetDefaultPos();
	void ReturnDefaultPos();
	void Update();
	bool IsCloset();
	int GetAction();
	double GetDistance2Ball();
	void SetDistance2Ball(double);
	bool IsInReligion();
	vector2d GetPos();
	vector2d GetTargetPos();
	bool PassTo(vector2d posTo);
	void MoveTo(PLAYERTYPE type, vector2d pos_pass);
	bool Shoot(bool);
	void StandAt(PLAYERTYPE type);
	void Support();
	static bool CanPass(vector2d, vector2d);

	void SetPos(vector2d _pos);
	void SetTypePlayer(PLAYERTYPE _typePlayer);
	PLAYERTYPE GetTypePlayer();
	bool IsMoveTo(vector2d _pos);
	void MoveTo(vector2d _pos);
	void AutoMove();
	bool CatchBall();
	bool GetBall();
	bool IsCanGetBall();
	bool BeThreaten(std::vector<Player*> team,Player* player);
	bool CanPass(vector2d target);

	static vector2d GetPositionOfType(PLAYERTYPE typePlayer);
	double GetAngleBetween(vector2d pos1, vector2d pos2);
	int CheckOpntInArea(area areatoCheck, vector2d& posOfOpnt); 
	vector2d PointIntersect(vector2d pos1, vector2d pos2, double point, bool x);
};
double DistanceXY(vector2d v1, vector2d v2);
